var apiwriter = require('apiwriter');
var fs = require('fs');

var config = {};
config.url = "http://localhost:1099/api";

apiwriter.setLogger(function(msg) {
    console.log(new Date().toLocaleTimeString('h:MM:ss l') + ' : ' + msg);
});

var writerOptions = {
    outputOptions: {
        jsonIndent: 3,
        outputRoot: __dirname,
        outputFolder: 'output'
    },
    // see request(options, callback) @ https://github.com/mikeal/request
    requestOptions: {
        url: config.url,
        followRedirect: false
    }
}

var outputPath = __dirname + '/output';
if (!fs.existsSync(outputPath))
    fs.mkdirSync(outputPath);

apiwriter.initialize(config, writerOptions);

apiwriter.resetOutput();
apiwriter.documentResources(__dirname + '/resources',
    function(area) {
        console.log('---------------------------------');
        console.log(area);
        console.log('---------------------------------');
    });





